package patten.xingwei.state;

import javax.naming.Name;

/**
 * Description：受伤状态
 * Author：zwenzhi
 * Date：2023/10/26 16:48
 */
public class InjuredState extends CharacterState {
    public InjuredState(Character character) {
        super(character);
    }

    @Override
    void handleAttack() {
        System.out.println("受伤状态,造成"+character.getAttack()/2+"点伤害");
    }

    @Override
    void handleDamage( int damage) {
        character.setHealth(Math.max(character.getHealth()-damage,0));
        System.out.println("受伤状态,受到"+damage+"点伤害,当前生命值:"+character.getHealth());
    }

    @Override
    void handleHeal(int healing) {
        character.setHealth(Math.min(character.getHealth()+healing,character.getMaxHealth()));
        System.out.println("受伤状态,恢复"+healing+"点血量,当前生命值:"+character.getHealth());
        if(character.getHealth()>character.getMaxHealth()/2){
            System.out.println("当前血量高于一半,移除受伤状态");
            this.character.setCharacterState(new NormalState(this.character));
        }
    }
}
